<script type="text/javascript" src="<?= base_url() ?>resource/js/layer/layer.js"></script>
<!--top结束-->
<div class="mian">
    <div class="mian1">
        <div class="mian2">
            <!--left start-->
            <?php $this->load->view('defaults/common/left'); ?>
            <!--left end-->
            <!--right start-->
            <div class="right">
                <!--breadcrumb start-->
                <div class="righta"><?= $this->breadcrumb->generateHTML(); ?> </div>
                <!--breadcrumb end-->
                <!-- contents start -->
                <div id="contents">
                    <div id="contents_container">
                        &nbsp;&nbsp;&nbsp;<?=lang('wms_zcsqdh')?>:<input type="text"  id="tran_order"   placeholder="example ZC****"/>
                        >>><button type="button" onclick="getZC()"  style="margin-right: 20px;width: 150px; height: 30px; margin-left: 20px;" ><?=lang('wms_djhqxx')?></button>
                        >>><button id='created_btn' disabled="true" type="button" onclick="createByZC()"  style="margin-right: 20px;width: 150px; height: 30px; margin-left: 20px;" ><?=lang('wms_cjrkdd')?></button><br/>
                        <div id="tran_order_table_show"></div>
                    </div>
                </div>
                <!-- contents end -->
            </div>
            <!--right end-->
            <div class="clear"></div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $('input[name="tran_order"]').focus();
    });
    function getZC(id){
        var tid= $("#tran_order").val();
        //loading层
        var LDindex;
        $.ajax({
            type:'post',
            timeout:60000,
            url:"<?= blang_url('wms/CreateReceivingOrder/get_zcsq/') ?>"+'/'+tid,
            beforeSend:function(XMLHttpRequest){
                LDindex = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                })
            }, 
            success: function (msg) {
                layer.close(LDindex);  
                obj=JSON.parse(msg);
                if(obj.totalCount<1){
                    alert('<?=lang('wms_tips_zbdzcsqd')?>')
                    return false;
                }
                var headArray=[];
                function parseHead(oneRow)
                {
                    for(var i in oneRow)
                    {
                        headArray[headArray.length] = i;
                    }
                }
                appendTable(obj.topics,"tran_order_table_show"); 
                $("#created_btn").attr("disabled",false); 
            },
            error: function (e, jqxhr, settings, exception) {
              
                layer.close(LDindex); 
            },
            complete : function(XMLHttpRequest,status){
                layer.close(LDindex); 
                if(status=='timeout'){
                    alert("<?=lang('wms_tips_timeout')?>");
                }
            }
        });
    }
    function createByZC(){
        //loading层
        var LDindex;
        var tid= $("#tran_order").val();
        $.ajax({
            type:'post',
            timeout:60000,
            url:"<?= blang_url('wms/CreateReceivingOrder/create_byzc/') ?>"+'/'+tid,
            beforeSend:function(XMLHttpRequest){
                LDindex = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                })
            }, 
            success: function (rs) {
                layer.close(LDindex); 
                obj=JSON.parse(rs);
                alert(obj.msg);
            },
            error: function (e, jqxhr, settings, exception) {

            },
            complete : function(XMLHttpRequest,status){
                layer.close(LDindex); 
                if(status=='timeout'){
                    alert("<?=lang('wms_tips_timeout')?>");
                }
            }
        });
    }
</script>

